<template>
	<view class="padding flex flex-direction">
		<button class="cu-btn bg-mauve margin-tb-sm lg" @click="toPay">立即支付</button>
	</view>
</template>

<script>
	import {
		order
	} from '@/config/mixins.js'
	export default {
		mixins: [order],
		props: {
			orderId: {
				type: String,
				default () {
					return ''
				}
			}
		},
		data() {
			return {}
		},
		methods: {
			toPay() {				
				let _this = this
				this.$api.tt_pay({
					order_id: this.orderId
				}).then(res => {
					console.log(res)
					if (res.code) {
						uni.requestPayment({
							provider: 'toutiao',
							service:1,
							_debug:1,
							orderInfo: res.data, //微信、支付宝订单数据
							success: function(res) {
								_this.$common.successToShow(res.msg, () => {
									_this.getOrderDetail('pay');
								})
							},
							fail: function(err) {
								console.log(err);
							},
							getOrderStatus: function(e) {
								console.log(e)
							}
						});
					} else {
						this.$common.errorToShow(res.msg)
					}
				})
			}
		}

	}
</script>

<style>

</style>
